<?php

namespace App\Models;


class Bridge extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'age_id', 'type_id', 'level_id', 'bridge_name', 'front_cover', 'longitude', 'latitude'
    ];

    /**
     * 关联详情
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function detail()
    {
        return $this->hasOne(BridgeDetail::class, 'bridge_id');
    }

    /**
     * 关联年代
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function age()
    {
        return $this->belongsTo(BridgeAge::class, 'age_id');
    }

    /**
     * 关联类型
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function type()
    {
        return $this->belongsTo(BridgeType::class, 'type_id');
    }

    /**
     * 关联级别
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function level()
    {
        return $this->belongsTo(BridgeLevel::class, 'level_id');
    }
}
